< previous page page_351 next page >

Page 351
(table continued from previous page)
PREFIXMEANING
API function. Thus, LPCSTR is a pointer to a string that will not be modified when passed to a function.
WUsed to indicate wide (Unicode) data. Thus, LPWCHAR is a pointer to a wide character. Note that a wide character is based on the unsigned short data type.
TC programmers can create applications that default to use Unicode or ANSI internally. The T prefix indicates a character data type that is Unicode in native Unicode applications, ANSI in native ANSI applications. Thus, LPTSTR will be LPSTR for an ANSI function entry point, LPWSTR for a Unicode function entry point.
Table T6-3: Common data type prefixes

Exploring the Common Windows Data Types
To help you become familiar with the most common Windows data types, let's take a close look at the first part of the header file called winnt.h, distributed with the Win32 Software Development Kit (SDK) and other developers' tools.2 Only the typedef statements are shown in Table T6-4.
typedef void *PVOID;The void data type is used for untyped data. You can't actually create a variable with type void. But you can create a pointer to a void. Such a pointer is considered a pointer to any type of data. PVOID is thus a pointer to any type of data.

typedef char CHAR;
typedef short SHORT;
typedef long LONG;

The simple explanation is that these three type defs are simple substitutions for those programmers who wish to use only uppercase data type3 names.

(table continued on next page)
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
2 Another good file to look at for base data types is the file winbase.h. Thanks to Microsoft's Open Tools program, all of the Win32 Software Development Kit header files are included on the CD that comes with this book.
7017a6ead0e3c4111b47a554df321e9f.gif 7017a6ead0e3c4111b47a554df321e9f.gif
3 The complex explanation is that these type declarations help a programmer create portable applications. Let's say you need a variable to be 16 bits. A short may be 16 bits under Win32, but the C language actually defines it as any size smaller or equal in size to an int, and larger or equal in size to a char. If you tried to compile your program on a version of C that defined short as 8 bits, you could run into trouble and have to change your variable types throughout your program. By using the SHORT typedef, all you would need to do is redefine it to a 16-bit type under the new compiler, and all of your variables and parameters defined as SHORT would compile correctly.

 
< previous page page_351 next page >